﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Formatting;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core;
using Cofe.Core.Logger;
using Cofe.Web.Feed;
using Cofe.Web.Interfaces;

namespace Cofe.Web
{
    public static class CofeWsServices
    {
        #region Constructor

       
        #endregion

        #region Methods

        #endregion

        #region Data

        private static ICofeWsSettings _cofewsSettings = null;
        private static IHttpMessageFormatterManager _messageFormatter = null;
        private static Func<IEnumerable<MediaTypeFormatter>> _mediaFormatterGetter =
            () => new List<MediaTypeFormatter>();
        private static ISyndicationItemBuilder _syndItemBuilder = null;
        private static IFeedManager _feedManager = null;

        #endregion

        #region Public Properties

        public static string EntryApiPath = "/api/entry";
        public static string ParseApiPath = "/api/parse";
        public static ICofeWsSettings CofeWsSettings { get { return _cofewsSettings ?? (_cofewsSettings = CofeServices.ServiceLocater.FindService<ICofeWsSettings>()); } }
        public static IHttpMessageFormatterManager HttpMessageFormatter { get { return _messageFormatter ?? (_messageFormatter = CofeServices.ServiceLocater.FindService<IHttpMessageFormatterManager>()); } }
        public static Func<IEnumerable<MediaTypeFormatter>> GetMediaFormatter { get { return _mediaFormatterGetter; } set { _mediaFormatterGetter = value; } }
        public static ISyndicationItemBuilder SyndicationItemBuilder { get { return _syndItemBuilder ?? (_syndItemBuilder = CofeServices.ServiceLocater.FindService<ISyndicationItemBuilder>()); } }
        public static IFeedManager Feeds { get { return _feedManager ?? (_feedManager = CofeServices.ServiceLocater.FindService<IFeedManager>()); } }
        #endregion
    }
}
